package com.young.shop.admin.service.impl;

import com.young.shop.admin.dao.CouponMapper;
import com.young.shop.admin.service.CouponService;
import com.young.shop.admin.utils.SnowFlake;
import com.young.shop.pojo.entity.Coupon;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CouponServiceImpl implements CouponService {

    @Autowired
    private CouponMapper couponMapper;

    @Override
    public int createCoupon(Coupon coupon) {
        //生成唯一code
        String code = SnowFlake.nextId()+ "";
        coupon.setCode(code);
        System.out.println(coupon.getCode());
        System.out.println(coupon.getName());
        return couponMapper.insertCoupon(coupon);
    }
}
